package com.lysj.merchant.merchant.controller;

import com.lysj.admin.utils.annotation.UserId;
import com.lysj.admin.utils.spring.foundation.base.BaseController;
import com.lysj.admin.utils.spring.foundation.base.BaseEntity;
import com.lysj.admin.utils.spring.foundation.jpa.RelationUtil;
import com.lysj.admin.utils.spring.foundation.pagination.PageVo;
import com.lysj.admin.utils.validation.annotation.Valid;
import com.lysj.admin.utils.web.Resp;
import com.lysj.merchant.management.domain.User;
import com.lysj.merchant.merchant.domain.Merchant;
import com.lysj.merchant.merchant.dto.MerchantUser;
import com.lysj.merchant.merchant.service.MerchantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Iterator;
import java.util.List;

/**
 * @author Created by wtl on 2019-03-12 17:25:12
 * @description 商户控制层
 */
@Slf4j
@RestController
@RequestMapping("/merchant/merchant")
public class MerchantController extends BaseController<Merchant> {

    @Resource
    private MerchantService merchantService;

    @Override
    public MerchantService getService() {
        return merchantService;
    }

    @Override
    public Resp list(Merchant entity, PageVo pageVo) {
        return new Resp().success(merchantService.list(entity, pageVo));
    }

    /**
     * @author Created by wtl on 2019/3/15 15:40
     * @Description 创建商户
     */
    @PostMapping("/save_merchant")
    public Resp save(@Valid MerchantUser entity) {
        return new Resp().success(merchantService.save(entity));
    }

    /**
     * @author Created by wtl on 2019/3/17 21:53
     * @Description 根据商户id查看对应的门店列表
     */
    @GetMapping("/find_store_info")
    public Resp findStoreInfo(String merchantId) {
        return new Resp().success(merchantService.findStoreInfo(merchantId));
    }


}
